class Solution {
    public int findRepeatNumber(int[] nums) {
        if (nums == null || nums.length == 0) return -1;
        for (int i = 0; i < nums.length; i++) {
            //System.out.println(Arrays.toString(nums));
            if (nums[i] != i) {
                if (nums[i] == nums[nums[i]]) {
                    return nums[i];
                } else {
                    nums[i] = nums[i] ^ nums[nums[i]];
                    nums[nums[i]] = nums[i] ^ nums[nums[i]];
                    nums[i] = nums[i] ^ nums[nums[i]];
                }
            }
        }
        return -1;
    }

    public static void main(String[] args) {
        Solution s = new Solution();
        int res = s.findRepeatNumber(new int[]{0, 1, 2, 3, 4, 11, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15});
        System.out.println(res);
    }
}
